feat(subscription): add skill subscription notification feature#356
Open
feat(subscription): add skill subscription notification feature#356
Conversation
150e399 to
284b099
Compare
Use .first() for h1 heading locator since skill detail page renders two h1 elements (page title + README heading). Add page-ready wait in second test before locating Subscribe button.
Published skills start in PENDING_REVIEW status with canInteract=false, so the SubscribeButton is not rendered. Use admin user to approve the review first, following the same pattern as search-seed and review-seed.
Include subscriptionCount in SkillDetailDTO and SkillDetailResponse so the frontend SubscribeButton receives the updated count after subscribe/unsubscribe mutations.
- Add visual separator between StarButton and SubscribeButton - Use optimistic updates in useToggleSubscription for instant feedback - Remove isLoading guard that caused button to unmount during refetch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
实现技能订阅通知功能。用户可手动订阅技能,当技能发布新版本或版本被撤回时,系统通过现有通知中心向订阅者推送通知。
Closes #307
变更内容
后端实现
skill_subscription表(Flyway V40 migration),包含skill_id、user_id、created_at字段SkillSubscription领域实体、SkillSubscriptionRepository接口及 JPA 实现SkillSubscriptionService领域服务,支持幂等订阅/取消订阅SkillSubscriptionControllerREST 控制器,提供订阅/取消订阅/查询状态接口Skill实体新增subscriptionCount字段,订阅/取消时原子更新MeController新增/me/subscriptions端点,支持分页查询用户订阅列表SkillVersionYankedEvent领域事件,在版本撤回时发布NotificationEventListener新增两个监听方法:SkillPublishedEvent→ 通知订阅者(排除发布者自己)SkillVersionYankedEvent→ 通知订阅者(排除操作者自己)SUBSCRIPTION_NEW_VERSION/SUBSCRIPTION_VERSION_YANKED前端实现
use-subscription.ts— 订阅状态查询和切换的 TanStack Query hookssubscribe-button.tsx— 订阅按钮组件(Bell 图标,显示订阅计数)/dashboard/subscriptions路由和MySubscriptionsPage页面notification-content.ts新增SUBSCRIPTION_NEW_VERSION和SUBSCRIPTION_VERSION_YANKED事件的中英文渲染meApi新增getSubscriptionsPage/getSubscriptions方法测试覆盖
SkillSubscriptionServiceTest(6 个用例 — 订阅/取消/幂等/状态查询)SkillSubscriptionControllerTest(7 个用例 — 三个端点的正常和异常场景)use-subscription.test.ts(hook 导出契约验证)skill-subscription.spec.ts(订阅/取消订阅流程、订阅列表页)API 端点
/api/web/skills/{skillId}/subscription/api/web/skills/{skillId}/subscription/api/web/skills/{skillId}/subscription/api/web/me/subscriptions?page=0&size=12质量门禁
make typecheck-web通过(0 errors)make lint-web通过(0 errors, 0 warnings)make test-frontend通过(550 tests passed)make test-backend-app通过(427 tests passed)make generate-api已执行且schema.d.ts已提交安全考虑
本地验证步骤
make dev-all启动本地环境/dashboard/subscriptions查看已订阅技能列表